/** The header provides numa support for the system

		It is designed to gratiously default to good behavior if numa is
		not supported.

*/

#ifndef _NUMA_DATAPATH_H_
#define _NUMA_DATAPATH_H_

// Constants
// no node preference in NUMA node pinning
#define NUMA_ALL_NODES -1

// Interface functions

// number of numa nodes
int numaNodeCount(void);

// on what node are we running now
int numaCurrentNode(void);


#ifdef USE_NUMA

#define MAX_CPU_SETS 10 // the total number of cpus is MAX_CPU_SETS*64

// the right headers
#define _GNU_SOURCE
#include <sched.h>
#include <numaif.h>
#include <numa.h>

inline int numaNodeCount(void){ return numa_max_node() ; }

inline int int numaCurrentNode(void){ return numa_preferred(); }

#else // no NUMA
// default behavior to have a uniform treatment

inline int numaNodeCount(void){ return 1; }

inline int numaCurrentNode(void){ return 0; }


#endif // USE_NUMA


#endif // _NUMA_DATAPATH_H_
